home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / MODEX.ZIP / MODEX.TXT
Encoding:
Text File  |  1997-01-10  |  24.0 KB  |  994 lines

  1.  
  2.  
  3.  
  4.  
  5.                    
  6.  
  7.                        INTRODUCTION TO MODE X 
  8.  
  9.                  
  10.  
  11.  
  12.                  By Robert Schmidt <robert@stud.unit.no>
  13.  
  14.  
  15.  
  16.  
  17.  
  18. Title:          INTRODUCTION TO MODE X
  19.  
  20.  
  21. Version:        1.8
  22.  
  23.  
  24. Author:         Robert Schmidt <robert@stud.unit.no>
  25.  
  26.  
  27. Copyright:      (C) 1993 of Ztiff Zox Softwear - refer to Status below.
  28.  
  29.  
  30. Last revision:  25-Nov-93 
  31.  
  32.  
  33. Figures:        1. M13ORG - memory organization in mode 13h
  34.  
  35.                 2. MXORG - memory organization in unchained modes
  36.  
  37.                                 
  38.  
  39. Status:         This article, its associated figures and source listings
  40.  
  41.                 named above, are all donated to the public domain.
  42.  
  43.                 Do with it whatever you like, but give credit where
  44.  
  45.                 credit is due.
  46.  
  47.  
  48.                 The standard disclaimer applies.
  49.  
  50.  
  51. Index:          0. ABSTRACT
  52.  
  53.                 1. INTRODUCTION TO THE VGA AND ITS 256-COLOR MODE
  54.  
  55.                 2. GETTING MORE PAGES AND PUTTING YOUR FIRST PIXEL
  56.  
  57.                 3. THE ROAD FROM HERE
  58.  
  59.                 4. BOOKS ON THE SUBJECT
  60.  
  61.                 5. BYE - FOR NOW
  62.  
  63.  
  64.  
  65. 0. ABSTRACT
  66.  
  67.  
  68. This text gives a fairly basic, yet technical, explanation to what, why
  69.  
  70. and how Mode X is.  It first tries to explain the layout of the VGA
  71.  
  72. memory and the shortcomings of the standard 320x200 256-color mode,
  73.  
  74. then gives instructions on how one can progress from mode 13h to a
  75.  
  76. multipage, planar 320x200 256-color mode, and from there to the
  77.  
  78. quasi-standard 320x240 mode, known as Mode X.
  79.  
  80.  
  81. A little experience in programming the standard VGA mode 13h
  82.  
  83. (320x200 in 256 colors) is assumed.  Likewise a good understanding of
  84.  
  85. hexadecimal notation and the concepts of segments and I/O ports is
  86.  
  87. assumed.  Keep a VGA reference handy, which at least should have
  88.  
  89. definitions of the VGA registers at bit level.
  90.  
  91.  
  92. Throughout the article, a simple graphics library for unchained (planar)
  93.  
  94. 256-color modes is developed.  The library supports the 320x200 and
  95.  
  96. 320x240 modes, active and visible pages, and writing and reading
  97.  
  98. individual pixels.
  99.  
  100.  
  101.  
  102. 1. INTRODUCTION TO THE VGA AND ITS 256-COLOR MODE
  103.  
  104.  
  105. Since its first appearance on the motherboards of the IBM PS/2 50, 60
  106.  
  107. and 80 models in 1987, the Video Graphics Array has been the de facto
  108.  
  109. standard piece of graphics hardware for IBM and compatible personal
  110.  
  111. computers.  The abbreviation, VGA, was to most people synonymous with
  112.  
  113. acceptable resolution (640x480 pixels), and a stunning rainbow of colors
  114.  
  115. (256 from a palette of 262,144), at least compared to the rather gory
  116.  
  117. CGA and EGA cards.
  118.  
  119.  
  120. Sadly, to use 256 colors, the VGA BIOS limited the users to 320x200
  121.  
  122. pixels, i.e. the well-known mode 13h.  This mode has one good and one
  123.  
  124. bad asset.  The good one is that each one of the 64,000 pixels is easily
  125.  
  126. addressable in the 64 Kb video memory segment at 0A000h.  Simply calculate
  127.  
  128. the offset using this formula:
  129.  
  130.  
  131. offset = (y * 320) + x;
  132.  
  133.  
  134. Set the byte at this address (0A000h:offset) to the color you want, and
  135.  
  136. the pixel is there.  Reading a pixel is just as simple: just read the
  137.  
  138. corresponding byte.  This was heaven, compared to the havoc of planes and
  139.  
  140. masking registers needed in 16-color modes.  Suddenly, the distance from a
  141.  
  142. graphics algorithm on paper to an implemented graphics routine in assembly
  143.  
  144. was cut down to a fraction.  The results were impressively fast, too!
  145.  
  146.  
  147. The bad asset is that mode 13h is also limited to only one page, i.e.
  148.  
  149. the VGA can hold only one screenful at any one time (plus 1536 pixels, or
  150.  
  151. about four lines).  Most 16-color modes let the VGA hold more than one page,
  152.  
  153. and this enables you to show one of the pages to the user, while drawing on
  154.  
  155. another page in the meantime.  Page flipping is an important concept in making
  156.  
  157. flicker free animations.  Nice looking and smooth scrolling is also almost
  158.  
  159. impossible in mode 13h using plain VGA hardware.
  160.  
  161.  
  162. Now, the alert reader might say: "Hold on a minute!  If mode 13h enables
  163.  
  164. only one page, this means that there is memory for only one page.  But I
  165.  
  166. know for a fact that all VGAs have at least 256 Kb RAM, and one 320x200
  167.  
  168. 256-color page should consume only 320*200=64000 bytes, which is less
  169.  
  170. than 64 Kb.  A standard VGA should room a little more than four 320x200
  171.  
  172. pages!"  Quite correct, and to see how the BIOS puts this limitation on
  173.  
  174. mode 13h, I'll elaborate a little on the memory organization of the VGA.
  175.  
  176.  
  177. The memory is separated into four bit planes.  The reason for this stems
  178.  
  179. from the EGA, where graphics modes were 16-color.  Using bit planes, the
  180.  
  181. designers chose to let each pixel on screen be addressable by a single
  182.  
  183. bit in a single byte in the video segment.  Assuming the palette has
  184.  
  185. not been modified from the default, each plane represent one of the EGA
  186.  
  187. primary colors: red, green, blue and intensity.  When modifying the bit
  188.  
  189. representing a pixel, the Write Plane Enable register is set to the
  190.  
  191. wanted color.  Reading is more complex and slower, since you can
  192.  
  193. only read from a single plane at a time, by setting the Read Plane
  194.  
  195. Select register.  Now, since each address in the video segment can
  196.  
  197. access 8 pixels, and there are 64 Kb addresses, 8 * 65,536 = 524,288
  198.  
  199. 16-color pixels can be accessed.  In a 320x200 16-color mode, this makes
  200.  
  201. for about 8 (524,288/(320*200)) pages, in 640x480 you get nearly 2
  202.  
  203. (524,288/(640*480)) pages.
  204.  
  205.  
  206. In a 256-color mode, the picture changes subtly.  The designers decided
  207.  
  208. to fix the number of bit planes to 4, so extending the logic above to 8
  209.  
  210. planes and 256 colors does not work.  Instead, one of their goals was to
  211.  
  212. make the 256-color mode as easily accessible as possible.  Comparing the
  213.  
  214. 8 pixels/address in 16-color modes to the 1-to-1 correspondence of
  215.  
  216. pixels and addresses of mode 13h, one can say that they have
  217.  
  218. succeeded, but at a certain cost.  For reasons I am not aware of, the
  219.  
  220. designers came up with the following effective, but memory-wasting
  221.  
  222. scheme:
  223.  
  224.  
  225. The address space of mode 13h is divided evenly across the four bit
  226.  
  227. planes.  When an 8-bit color value is written to a 16-bit address in the
  228.  
  229. VGA segment, a bit plane is automatically selected by the 2 least
  230.  
  231. significant bits of the address.  Then all 8 bits of the data is written
  232.  
  233. to the byte at the 16-bit address in the selected bitplane (have a look at
  234.  
  235. figure 1).  Reading works exactly the same way.  Since the bit planes are so
  236.  
  237. closely tied to the address, only every fourth byte in the video memory is
  238.  
  239. accessible, and 192 Kb of a 256 Kb VGA go to waste.  Eliminating the
  240.  
  241. need to bother about planes sure is convenient and beneficial, but to
  242.  
  243. most people the loss of 3/4 of the total VGA memory sounds just hilarious.
  244.  
  245.  
  246. To accomodate this new method of accessing video memory, the VGA
  247.  
  248. designers introduced a new configuration bit called Chain-4, which
  249.  
  250. resides as bit number 3 in index 4 of the Sequencer.  In 16-color modes,
  251.  
  252. the default state for this bit is off (zero), and the VGA operates as
  253.  
  254. described earlier.  In the VGA's standard 256-color mode, mode 13h, this
  255.  
  256. bit is turned on (set to one), and this turns the tieing of bit
  257.  
  258. planes and memory address on.
  259.  
  260.  
  261. In this state, the bit planes are said to be chained together, thus mode
  262.  
  263. 13h is often called a _chained mode_.
  264.  
  265.  
  266. Note that Chain-4 in itself is not enough to set a 256-color mode -
  267.  
  268. there are other registers which deals with the other subtle changes in
  269.  
  270. nature from 16 to 256 colors.  But, as we now will base our work with
  271.  
  272. mode X on mode 13h, which already is 256-color, we won't bother about
  273.  
  274. these for now.
  275.  
  276.  
  277.  
  278.  
  279. 2. GETTING MORE PAGES AND PUTTING YOUR FIRST PIXEL
  280.  
  281.  
  282. The observant reader might at this time suggest that clearing the
  283.  
  284. Chain-4 bit after setting mode 13h will give us access to all 256 Kb of
  285.  
  286. video memory, as the two least significant bits of the byte address
  287.  
  288. won't be `wasted' on selecting a bit plane.  This is correct.  You might
  289.  
  290. also start feeling a little uneasy, because something tells you that
  291.  
  292. you'll instantly loose the simple addressing scheme of mode 13h.  Sadly,
  293.  
  294. that is also correct.
  295.  
  296.  
  297. At the moment Chain-4 is cleared, each byte offset addresses *four*
  298.  
  299. sequential pixels, corresponding to the four planes addressed in 16-color
  300.  
  301. modes.  Every fourth pixel belong in the same plane.  Before writing to a byte
  302.  
  303. offset in the video segment, you should make sure that the 4-bit mask in the
  304.  
  305. Write Plane Enable register is set correctly, according to which of the four
  306.  
  307. addressable pixels you want to modify.  In essence, it works like a 16-color
  308.  
  309. mode with a twist.  See figure 2.
  310.  
  311.  
  312. So, is this mode X?  Not quite.  We need to elaborate to the VGA how to
  313.  
  314. fetch data for refreshing the monitor image.  Explaining the logic
  315.  
  316. behind this is beyond the scope of this getting-you-started text, and it
  317.  
  318. wouldn't be very interesting anyway.  Also, mode 13h has only 200 lines,
  319.  
  320. while I promised 240 lines.  I'll fix that later below.  Here is the minimum
  321.  
  322. snippet of code to initiate the 4 page variant of mode 13h (320x200), written
  323.  
  324. in plain C, using some DOS specific features (see header for a note about the
  325.  
  326. sources included):
  327.  
  328.  
  329. ----8<-------cut begin------
  330.  
  331.  
  332. /* width and height should specify the mode dimensions.  widthBytes
  333.  
  334.    specify the width of a line in addressable bytes. */
  335.  
  336.  
  337. int width, height, widthBytes;
  338.  
  339.  
  340. /* actStart specifies the start of the page being accessed by
  341.  
  342.    drawing operations.  visStart specifies the contents of the Screen
  343.  
  344.    Start register, i.e. the start of the visible page */
  345.  
  346.  
  347. unsigned actStart, visStart;
  348.  
  349.  
  350. /*
  351.  
  352.  * set320x200x256_X()
  353.  
  354.  *      sets mode 13h, then turns it into an unchained (planar), 4-page
  355.  
  356.  *      320x200x256 mode.
  357.  
  358.  */
  359.  
  360.  
  361. set320x200x256_X()
  362.  
  363.         {
  364.  
  365.  
  366.         union REGS r;
  367.  
  368.  
  369.         /* Set VGA BIOS mode 13h: */
  370.  
  371.  
  372.         r.x.ax = 0x0013;
  373.  
  374.         int86(0x10, &r, &r);
  375.  
  376.  
  377.         /* Turn off the Chain-4 bit (bit 3 at index 4, port 0x3c4): */
  378.  
  379.  
  380.         outport(SEQU_ADDR, 0x0604);
  381.  
  382.  
  383.         /* Turn off word mode, by setting the Mode Control register
  384.  
  385.            of the CRT Controller (index 0x17, port 0x3d4): */
  386.  
  387.  
  388.         outport(CRTC_ADDR, 0xE317);
  389.  
  390.  
  391.         /* Turn off doubleword mode, by setting the Underline Location
  392.  
  393.            register (index 0x14, port 0x3d4): */
  394.  
  395.  
  396.         outport(CRTC_ADDR, 0x0014);
  397.  
  398.  
  399.         /* Clear entire video memory, by selecting all four planes, then
  400.  
  401.            writing 0 to the entire segment. */
  402.  
  403.  
  404.         outport(SEQU_ADDR, 0x0F02);
  405.  
  406.         memset(vga+1, 0, 0xffff); /* stupid size_t exactly 1 too small */
  407.  
  408.         vga[0] = 0;
  409.  
  410.  
  411.         /* Update the global variables to reflect the dimensions of this
  412.  
  413.            mode.  This is needed by most future drawing operations. */
  414.  
  415.  
  416.         width   = 320;
  417.  
  418.         height  = 200;
  419.  
  420.  
  421.         /* Each byte addresses four pixels, so the width of a scan line
  422.  
  423.            in *bytes* is one fourth of the number of pixels on a line. */
  424.  
  425.  
  426.         widthBytes = width / 4;
  427.  
  428.  
  429.         /* By default we want screen refreshing and drawing operations
  430.  
  431.            to be based at offset 0 in the video segment. */
  432.  
  433.  
  434.         actStart = visStart = 0;
  435.  
  436.  
  437.         }
  438.  
  439.  
  440. ----8<-------cut end------
  441.  
  442.  
  443. As you can see, I've already provided some of the mechanics needed to
  444.  
  445. support multiple pages, by providing the actStart and visStart variables.
  446.  
  447. Selecting pages can be done in one of two contexts:
  448.  
  449.  
  450.         1) selecting the visible page, i.e. which page is visible on
  451.  
  452.            screen, and
  453.  
  454.  
  455.         2) selecting the active page, i.e. which page is accessed by
  456.  
  457.            drawing operations
  458.  
  459.  
  460. Selecting the active page is just a matter of offsetting our graphics
  461.  
  462. operations by the address of the start of the page, as demonstrated in
  463.  
  464. the put pixel routine below.  Selecting the visual page must be passed
  465.  
  466. in to the VGA, by setting the Screen Start register.  Sadly enough, the
  467.  
  468. resolution of this register is limited to one addressable byte, which
  469.  
  470. means four pixels in unchained 256-color modes.  Some further trickery is 
  471.  
  472. needed for 1-pixel smooth, horizontal scrolling, but I'll make that a subject
  473.  
  474. for later.  The setXXXStart() functions provided here accept byte
  475.  
  476. offsets as parameters, so they'll work in any mode.  If widthBytes and
  477.  
  478. height are set correctly, so will the setXXXPage() functions.
  479.  
  480.  
  481. ----8<-------cut begin------
  482.  
  483.  
  484. /*
  485.  
  486.  * setActiveStart() tells our graphics operations which address in video
  487.  
  488.  * memory should be considered the top left corner.
  489.  
  490.  */
  491.  
  492.  
  493. setActiveStart(unsigned offset)
  494.  
  495.         {
  496.  
  497.         actStart = offset;
  498.  
  499.         }
  500.  
  501.  
  502. /*
  503.  
  504.  * setVisibleStart() tells the VGA from which byte to fetch the first
  505.  
  506.  * pixel when starting refresh at the top of the screen.  This version
  507.  
  508.  * won't look very well in time critical situations (games for
  509.  
  510.  * instance) as the register outputs are not synchronized with the
  511.  
  512.  * screen refresh.  This refresh might start when the high byte is
  513.  
  514.  * set, but before the low byte is set, which produces a bad flicker.
  515.  
  516.  * I won't bother with this now.
  517.  
  518.  */
  519.  
  520.  
  521. setVisibleStart(unsigned offset)
  522.  
  523.         {
  524.  
  525.         visStart = offset;
  526.  
  527.         outport(CRTC_ADDR, 0x0C);               /* set high byte */
  528.  
  529.         outport(CRTC_ADDR+1, visStart >> 8);
  530.  
  531.         outport(CRTC_ADDR, 0x0D);               /* set low byte */
  532.  
  533.         outport(CRTC_ADDR+1, visStart & 0xff);
  534.  
  535.         }
  536.  
  537.  
  538. /*
  539.  
  540.  * setXXXPage() sets the specified page by multiplying the page number
  541.  
  542.  * with the size of one page at the current resolution, then handing the
  543.  
  544.  * resulting offset value over to the corresponding setXXXStart()
  545.  
  546.  * function.  The first page number is 0.
  547.  
  548.  */
  549.  
  550.  
  551. setActivePage(int page)
  552.  
  553.         {
  554.  
  555.         setActiveStart(page * widthBytes * height);
  556.  
  557.         }
  558.  
  559.  
  560. setVisiblePage(int page)
  561.  
  562.         {
  563.  
  564.         setVisibleStart(page * widthBytes * height);
  565.  
  566.         }
  567.  
  568.  
  569. ----8<-------cut end------
  570.  
  571.  
  572. Due to the use of bit planes, the graphics routines tend to get more
  573.  
  574. complex than in mode 13h, and your first versions will generally tend to
  575.  
  576. be a little slower than mode 13h algorithms.  Here's a put pixel routine
  577.  
  578. for any unchained 256-color mode (it assumes that the 'width' variable
  579.  
  580. from the above code is set correctly).  Optimizing is left as an exercise
  581.  
  582. to you, the reader.  This will be the only drawing operation I'll cover
  583.  
  584. in this article, but all general primitives like lines and circles can be 
  585.  
  586. based on this routine.  (You'll probably not want to do that though, due
  587.  
  588. to the inefficiency.)
  589.  
  590.  
  591. ----8<-------cut begin------
  592.  
  593.  
  594. putPixel_X(int x, int y, char color)
  595.  
  596.         {
  597.  
  598.  
  599.         /* Each address accesses four neighboring pixels, so set
  600.  
  601.            Write Plane Enable according to which pixel we want
  602.  
  603.            to modify.  The plane is determined by the two least
  604.  
  605.            significant bits of the x-coordinate: */
  606.  
  607.  
  608.         outportb(0x3c4, 0x02);
  609.  
  610.         outportb(0x3c5, 0x01 << (x & 3));
  611.  
  612.  
  613.         /* The offset of the pixel into the video segment is
  614.  
  615.            offset = (width * y + x) / 4, and write the given
  616.  
  617.            color to the plane we selected above.  Heed the active
  618.  
  619.            page start selection. */
  620.  
  621.  
  622.         vga[(unsigned)(widthBytes * y) + (x / 4) + actStart] = color;
  623.  
  624.  
  625.         }
  626.  
  627.  
  628. char getPixel_X(int x, int y)
  629.  
  630.         {
  631.  
  632.  
  633.         /* Select the plane from which we must read the pixel color: */
  634.  
  635.  
  636.         outport(GRAC_ADDR, 0x04);
  637.  
  638.         outport(GRAC_ADDR+1, x & 3);
  639.  
  640.  
  641.         return vga[(unsigned)(widthBytes * y) + (x / 4) + actStart];
  642.  
  643.  
  644.         }
  645.  
  646.  
  647. ----8<-------cut end------
  648.  
  649.  
  650.  
  651. However, by now you should be aware of that the Write Plane Enable
  652.  
  653. register isn't limited to selecting just one bit plane, like the
  654.  
  655. Read Plane Select register is.  You can enable any combination of all
  656.  
  657. four to be written.  This ability to access 4 pixels with one
  658.  
  659. instruction helps quadrupling the speed in certain respects, especially when 
  660.  
  661. drawing horizontal lines and filling polygons of a constant color.  Also, most 
  662.  
  663. block algorithms can be optimized in various ways so that they need only
  664.  
  665. a constant number of OUTs (typically four) to the Write Plane Enable
  666.  
  667. register.  OUT is a relatively slow instruction.
  668.  
  669.  
  670. The gained ability to access the full 256 Kb of memory on a standard
  671.  
  672. VGA enables you to do paging and all the goodies following from that:
  673.  
  674. smooth scrolling over large maps, page flipping for flicker free
  675.  
  676. animation... and I'll leave something for your own imagination.
  677.  
  678.  
  679. In short, the stuff gained from unchaining mode 13h more than 
  680.  
  681. upweighs the additional complexity of using a planar mode.  
  682.  
  683.  
  684. Now, the resolution of the mode is of little interest in this
  685.  
  686. context.  Nearly any 256-color resolution from (about) 80x8 to 400x300
  687.  
  688. is available for most VGAs.  I'll dwell particularly by 320x240, as this
  689.  
  690. is the mode that Michael Abrash introduced as 'Mode X' in his DDJ
  691.  
  692. articles.  It is also the resolution that most people refer to when
  693.  
  694. using that phrase.
  695.  
  696.  
  697. The good thing about the 320x240 mode is that the aspect ratio is
  698.  
  699. 1:1, which means that each pixel is 'perfectly' square, i.e. not
  700.  
  701. rectangular like in 320x200.  An ellipse drawn with the same number of
  702.  
  703. pixels along both main axes will look like a perfect circle in 320x240,
  704.  
  705. but like a subtly tall ellipse in 320x200.
  706.  
  707.  
  708. Here's a function which sets the 320x240 mode.  You'll notice that
  709.  
  710. it depends on the first piece of code above:
  711.  
  712.  
  713. ----8<-------cut begin------
  714.  
  715.  
  716. set320x240x256_X()
  717.  
  718.         {
  719.  
  720.  
  721.         /* Set the unchained version of mode 13h: */
  722.  
  723.  
  724.         set320x200x256_X();
  725.  
  726.  
  727.         /* Modify the vertical sync polarity bits in the Misc. Output
  728.  
  729.            Register to achieve square aspect ratio: */
  730.  
  731.  
  732.         outportb(0x3C2, 0xE3);
  733.  
  734.  
  735.         /* Modify the vertical timing registers to reflect the increased
  736.  
  737.            vertical resolution, and to center the image as good as
  738.  
  739.            possible: */
  740.  
  741.  
  742.         outport(0x3D4, 0x2C11);         /* turn off write protect */
  743.  
  744.         outport(0x3D4, 0x0D06);         /* vertical total */
  745.  
  746.         outport(0x3D4, 0x3E07);         /* overflow register */
  747.  
  748.         outport(0x3D4, 0xEA10);         /* vertical retrace start */
  749.  
  750.         outport(0x3D4, 0xAC11);         /* vertical retrace end AND wr.prot */
  751.  
  752.         outport(0x3D4, 0xDF12);         /* vertical display enable end */
  753.  
  754.         outport(0x3D4, 0xE715);         /* start vertical blanking */
  755.  
  756.         outport(0x3D4, 0x0616);         /* end vertical blanking */
  757.  
  758.  
  759.         /* Update mode info, so future operations are aware of the
  760.  
  761.            resolution: */
  762.  
  763.  
  764.         height = 240;
  765.  
  766.  
  767.         }
  768.  
  769.  
  770. ----8<-------cut end------
  771.  
  772.  
  773.  
  774. As you've figured out, this mode will be completely compatible with the
  775.  
  776. utility functions presented earlier, thanks to the global variable
  777.  
  778. 'height'.  Boy, am I foreseeing or what!
  779.  
  780.  
  781. Other resolutions are achieved through giving other values to the sync
  782.  
  783. timing registers of the VGA, but this is quite a large and complex
  784.  
  785. subject, so I'll postpone this to later, if ever.
  786.  
  787.  
  788. Anyway, I hope I've helped getting you started using mode X.  As far as
  789.  
  790. I know, the two modes I've used above should work on *any* VGA and Super
  791.  
  792. VGA available, so this is pretty stable stuff.  Let me know of any 
  793.  
  794. trouble, and -
  795.  
  796.                         good luck!
  797.  
  798.  
  799.  
  800.  
  801. 3. THE ROAD FROM HERE
  802.  
  803.  
  804. I'm providing information on various libraries and archives which relate
  805.  
  806. to what this article deals with.  If you want me to add anything to this
  807.  
  808. list (for future articles), let me know, although I can't promise anything.
  809.  
  810. I am assuming you have ftp access.
  811.  
  812.  
  813.  
  814. wuarchive.wustl.edu:/pub/MSDOS_UPLOADS/programming/xlib06.zip
  815.  
  816.  
  817. This is the current de facto C/assembler library for programming
  818.  
  819. unchained modes (do not confuse with a X Windows library).  All sources
  820.  
  821. are included, and the library is totally free.  It has functions for
  822.  
  823. pixels, lines, circles, bezier curves, mouse handling, sprites (bitmaps),
  824.  
  825. compiled bitmaps, and supports a number of resolutions.  The version number
  826.  
  827. ('06') is current as of November 1993.
  828.  
  829.  
  830.  
  831. graphprg.zip
  832.  
  833.  
  834. Michael Abrash' articles in Doctor Dobbs Journal is always mentioned
  835.  
  836. with awe.  In this 350 Kb archive, most of his interesting stuff has
  837.  
  838. been gathered.  Read about Mode X development and techniques from month
  839.  
  840. to month.  Included is also all the individual source code snippets from
  841.  
  842. each article, and also the full XSHARP library providing linedrawing,
  843.  
  844. polygons, bitmaps, solid 3D projection and speedy rendering, and even an
  845.  
  846. implementation of 2D texture mapping (can be used for quasi-3D texture
  847.  
  848. mapping), plus an article on assembly optimization on the i86 processor
  849.  
  850. family.  Definitely recommended.
  851.  
  852.  
  853.  
  854. oak.oakland.edu:/pub/msdos/vga/vgadoc2.zip
  855.  
  856.  
  857. This is a bare bones VGA register reference.  It also contains register
  858.  
  859. references for the CGA, EGA and Hercules cards, in addition to dozens of
  860.  
  861. SuperVGAs.  Check out the BOOKS section for some decent VGA references
  862.  
  863. though - you don't want to start tweaking without a real one.
  864.  
  865.  
  866.  
  867. wuarchive.wustl.edu:/pub/MSDOS_UPLOADS/programming/tweak15b.zip
  868.  
  869.  
  870. TWEAK might be of interest to the more adventurous reader.  TWEAK lets you
  871.  
  872. play around with the registers of the VGA in an interactive manner.
  873.  
  874. Various testing screens for viewing your newmade modes are applied at
  875.  
  876. the press of a key.  Version 1.5 adds a test screen which autodetects your 
  877.  
  878. graphics mode and displays various information about resolutions etc.
  879.  
  880. Keep a VGA reference handy.  Don't try it if this is the first time you've 
  881.  
  882. heard of 'registers' or 'mode X' or 'tweaking'.  I was planning a version
  883.  
  884. based on the Turbo Vision interface, but time has been short.  Maybe later!
  885.  
  886.  
  887.  
  888.  
  889.  
  890. 4. BOOKS ON THE SUBJECT
  891.  
  892.  
  893. Extremely little has been published in written form about using
  894.  
  895. 'Mode X'-style modes.  Below are some books which cover VGA programming
  896.  
  897. at varying degrees of technical level, but the only one to mention
  898.  
  899. unchained modes and Mode X, is Michael Abrash'.  I'd get one of the VGA
  900.  
  901. references first, though.
  902.  
  903.  
  904.   o  George Sutty & Steve Blair : "Advanced Pogrammer's Guide to the
  905.  
  906.      EGA/VGA" from Brady.  A bit old perhaps, but covers all *standard*
  907.  
  908.      EGA/VGA registers, and discusses most BIOS functions and other
  909.  
  910.      operations.  Contains disk with C/Pascal/assembler source code.
  911.  
  912.      There's a sequel out for SuperVGAs, which I haven't seen.
  913.  
  914.  
  915.   o  Michael Abrash : "Power Graphics Programming" from QUE/Programmer's
  916.  
  917.      Journal.  Collections of (old) articles from Programmer's Journal on
  918.  
  919.      EGA/VGA, read modes and write modes, animation, tweaking (320x400
  920.  
  921.      and 360x480).  His newer ravings in DDJ covers fast 256-color
  922.  
  923.      bitmaps, compiled bitmaps, polygons, 3D graphics, texture mapping
  924.  
  925.      among other stuff.
  926.  
  927.  
  928.   o  Richard F. Ferraro : "Programmer's Guide to the EGA and VGA video
  929.  
  930.      cards including Super VGA".  I don't have this one, but heard it's
  931.  
  932.      nice.  Detailed coverage of all EGA/VGA registers.  The Super VGA
  933.  
  934.      reference makes it attractive.
  935.  
  936.  
  937.   o  Richard Wilton : "Programmer's Guide to PC & PS/2 Video Systems"
  938.  
  939.      Less technical, more application/algorithm oriented.  Nice enough,
  940.  
  941.      even though it is a bit outdated, in that he discusses CGA and
  942.  
  943.      Hercules cards just as much as EGA/VGA.
  944.  
  945.  
  946.  
  947.  
  948.  
  949. 5. BYE - FOR NOW
  950.  
  951.  
  952. I am considering writing a text describing in more detail the process of
  953.  
  954. using TWEAK to achieve the VGA resolution you want or need.  However, I
  955.  
  956. thought I'd let this document go first, and see if I get any reactions.
  957.  
  958. If I don't, I'll stop.  Feel free to forward any suggestions,
  959.  
  960. criticisms, bombs and beers.
  961.  
  962.  
  963. I can be reached via:
  964.  
  965.  
  966.   o  e-mail: robert@stud.unit.no
  967.  
  968.  
  969.   o  land mail:
  970.  
  971.  
  972.      Robert Schmidt
  973.  
  974.      Stud.post 170
  975.  
  976.      NTH
  977.  
  978.      N-7034 Trondheim
  979.  
  980.      NORWAY
  981.  
  982.  
  983. Nothing would encourage or please me more than a postcard from where you
  984.  
  985. live!
  986.  
  987.  
  988. Zox3D 
  989.  
  990.  
  991.  
  992. Available via ftp :
  993.  
  994. ftp.wustl.edu:/pub/MSDOS_UPLOADS